package com.itheima.controller;

import com.itheima.domain.mongo.UserFreeze;
import com.itheima.manager.UserFreezeManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.POST;
import java.util.Map;

/**
 * @author ZhuHongKai
 * @version 1.0
 * @ClassName UserFreezeController
 * @date 2022/11/10 23:01
 */
@RestController
public class UserFreezeController {
    @Autowired
    UserFreezeManager userFreezeManager;


    // 用户冻结操作
    @RequestMapping(value = "/manage/users/freeze",method = RequestMethod.POST)
    public ResponseEntity freezeSave(@RequestBody UserFreeze userFreeze){
        return userFreezeManager.freezeSave(userFreeze);
    }

    // 用户解冻操作
    @RequestMapping(value = "/manage/users/unfreeze",method = RequestMethod.POST)
    public ResponseEntity unfreeze(@RequestBody Map<String,Object> map) {
        Long userId = Long.parseLong(String.valueOf(map.get("userId")));
        String reasonsForThawing = (String) map.get("frozenRemarks");
        return userFreezeManager.unfreeze(userId,reasonsForThawing);
    }
}
